package com.mapper;

import com.POJO.TeacherSubjectClass;
import java.util.List;

import org.apache.ibatis.annotations.*;

/**
 * @Package com.mapper
 * @Date 2024-05-23 11:32
 * 教师-班级科目相关数据库操作
 */

@Mapper
public interface TeacherSubjectClassMapper {
    @Select("select * from teacher_subjects_classes where teacher_id =#{tescherId};")
    // 根据教师ID获取其教授的所有科目和班级关系
    List<TeacherSubjectClass> getTeacherSubjectClassByTeacherId(int teacherId);

    // 新增教师-科目-班级关系
    @Insert("insert into teacher_subjects_classes(teacher_id,subject_id,class_id)values (#{teacherId},#{subjectId},#{classId})")
    @Options(useGeneratedKeys = true, keyProperty = "teacherId")
    void insertTeacherSubjectClass(TeacherSubjectClass teacherSubjectClass);

    // 删除教师-科目-班级关系
    @Delete("delete from teacher_subjects_classes where class_id=#{id}")void deleteTeacherSubjectClass(int id);

    @Select("SELECT * FROM teacher_subjects_classes WHERE subject_id = #{subjectId}")
    List<TeacherSubjectClass> getTeacherSubjectClassBySubjectId(int subjectId);
}
